
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Mybatis框架 · 书名</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="作者">
        <meta name="identifier" content="图书编号" scheme="ISBN">
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="SpringBoot.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    书名
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Books</li>
        
        
    
        <li class="chapter " data-level="2.1" >
            
                <span>
            
                    
                    Java
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../java/001环境变量.html">
            
                <a href="../java/001环境变量.html">
            
                    
                    001环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../java/002Java初体验.html">
            
                <a href="../java/002Java初体验.html">
            
                    
                    002Java初体验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../java/003变量命名及数据类型.html">
            
                <a href="../java/003变量命名及数据类型.html">
            
                    
                    003变量命名及数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="../java/004运算符.html">
            
                <a href="../java/004运算符.html">
            
                    
                    004运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="../java/005选择结构.html">
            
                <a href="../java/005选择结构.html">
            
                    
                    005选择结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6" data-path="../java/006循环结构.html">
            
                <a href="../java/006循环结构.html">
            
                    
                    006循环结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="../java/007数组.html">
            
                <a href="../java/007数组.html">
            
                    
                    007数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="../java/008类和对象方法.html">
            
                <a href="../java/008类和对象方法.html">
            
                    
                    008类和对象方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.9" data-path="../java/009构造方法.html">
            
                <a href="../java/009构造方法.html">
            
                    
                    009构造方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.10" data-path="../java/010封装与关键字static.html">
            
                <a href="../java/010封装与关键字static.html">
            
                    
                    010封装与关键字Static
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.11" data-path="../java/011 继承.html">
            
                <a href="../java/011 继承.html">
            
                    
                    011 继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.12" data-path="../java/012方法重写.html">
            
                <a href="../java/012方法重写.html">
            
                    
                    012方法重写
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.13" data-path="../java/013多态.html">
            
                <a href="../java/013多态.html">
            
                    
                    013多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.14" data-path="../java/014抽象类抽象方法.html">
            
                <a href="../java/014抽象类抽象方法.html">
            
                    
                    014抽象类抽象方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.15" data-path="../java/015接口.html">
            
                <a href="../java/015接口.html">
            
                    
                    015接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.16" data-path="../java/016异常.html">
            
                <a href="../java/016异常.html">
            
                    
                    016异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.17" data-path="../java/017集合.html">
            
                <a href="../java/017集合.html">
            
                    
                    017集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.18" data-path="../java/017集合2.html">
            
                <a href="../java/017集合2.html">
            
                    
                    017集合2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.19" data-path="../java/018泛型.html">
            
                <a href="../java/018泛型.html">
            
                    
                    018泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.20" data-path="../java/019Collections算法类.html">
            
                <a href="../java/019Collections算法类.html">
            
                    
                    019Collections算法类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.21" data-path="../java/020枚举.html">
            
                <a href="../java/020枚举.html">
            
                    
                    020枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.22" data-path="../java/021包装类.html">
            
                <a href="../java/021包装类.html">
            
                    
                    021包装类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.23" data-path="../java/022常用类.html">
            
                <a href="../java/022常用类.html">
            
                    
                    022常用类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.24" data-path="../java/023File类.html">
            
                <a href="../java/023File类.html">
            
                    
                    023File类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.25" data-path="../java/024IO流.html">
            
                <a href="../java/024IO流.html">
            
                    
                    024IO流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.26" data-path="../java/025多线程.html">
            
                <a href="../java/025多线程.html">
            
                    
                    025多线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.27" data-path="../java/025多线程线程池.html">
            
                <a href="../java/025多线程线程池.html">
            
                    
                    025多线程线程池
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.28" data-path="../java/026网络编程Socket.html">
            
                <a href="../java/026网络编程Socket.html">
            
                    
                    026网络编程Socket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.29" data-path="../java/027XML解析.html">
            
                <a href="../java/027XML解析.html">
            
                    
                    027XML解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.30" data-path="../java/028 注解.html">
            
                <a href="../java/028 注解.html">
            
                    
                    028 注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.31" data-path="../java/029 Lambda表达式.html">
            
                <a href="../java/029 Lambda表达式.html">
            
                    
                    029 Lambda表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.32" data-path="../java/029 反射.html">
            
                <a href="../java/029 反射.html">
            
                    
                    029 反射
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" >
            
                <span>
            
                    
                    Mybatis
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="../mybatis/MyBatis.html">
            
                <a href="../mybatis/MyBatis.html">
            
                    
                    MyBatis
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1.1" >
            
                <span>
            
                    
                    MyBatis
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" >
            
                <span>
            
                    
                    Mysql
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../mysql/01 SQL通用语法.html">
            
                <a href="../mysql/01 SQL通用语法.html">
            
                    
                    01 SQL通用语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../mysql/02 DDL.html">
            
                <a href="../mysql/02 DDL.html">
            
                    
                    02 DDL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../mysql/03 DML.html">
            
                <a href="../mysql/03 DML.html">
            
                    
                    03 DML
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="../mysql/04 DQL.html">
            
                <a href="../mysql/04 DQL.html">
            
                    
                    04 DQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="../mysql/05 DCL.html">
            
                <a href="../mysql/05 DCL.html">
            
                    
                    05 DCL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="../mysql/06 函数.html">
            
                <a href="../mysql/06 函数.html">
            
                    
                    06 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="../mysql/07 约束.html">
            
                <a href="../mysql/07 约束.html">
            
                    
                    07 约束
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="../mysql/08 多表查询.html">
            
                <a href="../mysql/08 多表查询.html">
            
                    
                    08 多表查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.9" data-path="../mysql/09 事务.html">
            
                <a href="../mysql/09 事务.html">
            
                    
                    09 事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.10" data-path="../mysql/999zzz.html">
            
                <a href="../mysql/999zzz.html">
            
                    
                    999zzz
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.11" data-path="../mysql/MySql.html">
            
                <a href="../mysql/MySql.html">
            
                    
                    MySql
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.12" data-path="../mysql/sql.html">
            
                <a href="../mysql/sql.html">
            
                    
                    Sql
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" >
            
                <span>
            
                    
                    Spring
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../spring/spring.html">
            
                <a href="../spring/spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" >
            
                <span>
            
                    
                    SpringMVC
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../springMVC/springMVC.html">
            
                <a href="../springMVC/springMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" >
            
                <span>
            
                    
                    整合
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="2.6.1" data-path="Mybatis框架.html">
            
                <a href="Mybatis框架.html">
            
                    
                    Mybatis框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.2" data-path="SpringBoot.html">
            
                <a href="SpringBoot.html">
            
                    
                    SpringBoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.3" data-path="springmvc框架.html">
            
                <a href="springmvc框架.html">
            
                    
                    Springmvc框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.4" data-path="spring框架.html">
            
                <a href="spring框架.html">
            
                    
                    Spring框架
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Mybatis框架</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="mybatis&#x6846;&#x67B6;">Mybatis&#x6846;&#x67B6;</h1>
<h2 id="mybatis&#x7B80;&#x4ECB;">MyBatis&#x7B80;&#x4ECB;</h2>
<p>MyBatis &#x662F;&#x4E00;&#x6B3E;&#x4F18;&#x79C0;&#x7684;&#x6301;&#x4E45;&#x5C42;&#x6846;&#x67B6;&#xFF0C;&#x5B83;&#x652F;&#x6301;&#x81EA;&#x5B9A;&#x4E49; SQL&#x3001;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;&#x4EE5;&#x53CA;&#x9AD8;&#x7EA7;&#x6620;&#x5C04;&#x3002;MyBatis &#x514D;&#x9664;&#x4E86;&#x51E0;&#x4E4E;&#x6240;&#x6709;&#x7684; JDBC &#x4EE3;&#x7801;&#x4EE5;&#x53CA;&#x8BBE;&#x7F6E;&#x53C2;&#x6570;&#x548C;&#x83B7;&#x53D6;&#x7ED3;&#x679C;&#x96C6;&#x7684;&#x5DE5;&#x4F5C;&#x3002;MyBatis &#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x7B80;&#x5355;&#x7684; XML &#x6216;&#x6CE8;&#x89E3;&#x6765;&#x914D;&#x7F6E;&#x548C;&#x6620;&#x5C04;&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x3001;&#x63A5;&#x53E3;&#x548C; Java POJO&#xFF08;Plain Old Java Objects&#xFF0C;&#x666E;&#x901A;&#x8001;&#x5F0F; Java &#x5BF9;&#x8C61;&#xFF09;&#x4E3A;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x7684;&#x8BB0;&#x5F55;</p>
<p>2010&#x5E74;&#x8FD9;&#x4E2A;&#x9879;&#x76EE;&#x7531;apache software foundation &#x8FC1;&#x79FB;&#x5230;&#x4E86;google code&#xFF0C;&#x5E76;&#x4E14;&#x6539;&#x540D;&#x4E3A;MyBatis &#x3002;2013&#x5E74;11&#x6708;&#x8FC1;&#x79FB;&#x5230;Github&#x3002;</p>
<p><strong>&#x56DE;&#x987E;JDBC&#x7684;&#x4F7F;&#x7528;&#x6B65;&#x9AA4;&#xFF1A;</strong></p>
<ul>
<li>1.&#x52A0;&#x8F7D;&#x9A71;&#x52A8;       </li>
</ul>
<pre><code class="lang-java">Class.forName(<span class="hljs-string">&quot;com.mysql.jdbc.Driver&quot;</span>);
</code></pre>
<ul>
<li>2.&#x83B7;&#x53D6;&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;</li>
</ul>
<pre><code class="lang-java">DiverManerger.getConnection(url,username,password)
</code></pre>
<ul>
<li>3.&#x83B7;&#x53D6;&#x6267;&#x884C;sql&#x7684;Statement&#x5BF9;&#x8C61;</li>
</ul>
<pre><code class="lang-java">connection.CreateStatement();
</code></pre>
<ul>
<li>4.&#x6267;&#x884C;sql&#x8BED;&#x53E5;</li>
<li>5.&#x5904;&#x7406;&#x7ED3;&#x679C;&#x96C6;</li>
<li>6.&#x91CA;&#x653E;&#x8FDE;&#x63A5;</li>
</ul>
<pre><code class="lang-java">connection.Close()
</code></pre>
<p><strong>&#x4E0E;JDBC&#x76F8;&#x6BD4;&#xFF1A;</strong></p>
<ol>
<li>Mybatis&#x901A;&#x8FC7;&#x53C2;&#x6570;&#x6620;&#x5C04;&#x65B9;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x53C2;&#x6570;&#x7075;&#x6D3B;&#x7684;&#x914D;&#x7F6E;&#x5728;SQL&#x8BED;&#x53E5;&#x4E2D;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x907F;&#x514D;&#x5728;Java&#x7C7B;&#x4E2D;&#x914D;&#x7F6E;&#x53C2;&#x6570;</li>
<li>Mybatis&#x901A;&#x8FC7;&#x8F93;&#x51FA;&#x6620;&#x5C04;&#x673A;&#x5236;&#xFF0C;&#x5C06;&#x7ED3;&#x679C;&#x96C6;&#x7684;&#x68C0;&#x7D22;&#x81EA;&#x52A8;&#x6620;&#x5C04;&#x6210;&#x76F8;&#x5E94;&#x7684;Java&#x5BF9;&#x8C61;&#xFF0C;&#x907F;&#x514D;&#x5BF9;&#x7ED3;&#x679C;&#x96C6;&#x624B;&#x5DE5;&#x68C0;&#x7D22;</li>
<li>Mybatis&#x53EF;&#x4EE5;&#x901A;&#x8FC7;Xml&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x5BF9;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x8FDB;&#x884C;&#x7BA1;&#x7406;</li>
</ol>
<h2 id="mybatis&#x6574;&#x4F53;&#x67B6;&#x6784;&#x53CA;&#x8FD0;&#x884C;&#x6D41;&#x7A0B;">MyBatis&#x6574;&#x4F53;&#x67B6;&#x6784;&#x53CA;&#x8FD0;&#x884C;&#x6D41;&#x7A0B;</h2>
<p>Mybatis&#x6574;&#x4F53;&#x6784;&#x9020;&#x7531; &#x6570;&#x636E;&#x6E90;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3001;Sql&#x6620;&#x5C04;&#x6587;&#x4EF6;&#x3001;&#x4F1A;&#x8BDD;&#x5DE5;&#x5382;&#x3001;&#x4F1A;&#x8BDD;&#x3001;&#x6267;&#x884C;&#x5668;&#x548C;&#x5E95;&#x5C42;&#x5C01;&#x88C5;&#x5BF9;&#x8C61;&#x7EC4;&#x6210;</p>
<h3 id="1&#x6570;&#x636E;&#x6E90;&#x914D;&#x7F6E;&#x6587;&#x4EF6;">1.&#x6570;&#x636E;&#x6E90;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h3>
<p>&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x7684;&#x65B9;&#x5F0F;&#x5C06;&#x6570;&#x636E;&#x5E93;&#x7684;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#x4ECE;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x72EC;&#x7ACB;&#x51FA;&#x6765;&#xFF0C;&#x7531;&#x72EC;&#x7ACB;&#x7684;&#x6A21;&#x5757;&#x7BA1;&#x7406;&#x548C;&#x914D;&#x7F6E;&#x3002;Mybatis&#x7684;&#x6570;&#x636E;&#x6E90;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x5305;&#x542B;&#x6570;&#x636E;&#x5E93;&#x9A71;&#x52A8;&#x3001;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x5730;&#x5740;&#x3001;&#x7528;&#x6237;&#x540D;&#x5BC6;&#x7801;&#x3001;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x7B49;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x8FDE;&#x63A5;&#x6C60;&#x7684;&#x8FDE;&#x63A5;&#x6570;&#x3001;&#x7A7A;&#x95F2;&#x65F6;&#x95F4;&#x7B49;</p>
<p>&#x4E00;&#x4E2A;MapConfig.xml&#x57FA;&#x672C;&#x7684;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-java">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE configuration
  PUBLIC &quot;-//mybatis.org//DTD Config 3.0//EN&quot;
  &quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;&gt;
&lt;configuration&gt;
  &lt;environments default=&quot;development&quot;&gt;
    &lt;environment id=&quot;development&quot;&gt;
   &lt;!-- &#x4E8B;&#x52A1;&#x7684;&#x7BA1;&#x7406; JDBC  MANAGED--&gt;
      &lt;transactionManager type=&quot;JDBC&quot;/&gt;
   &lt;!-- &#x6570;&#x636E;&#x6E90; POOLED UNPOOLED JNDI --&gt;
      &lt;dataSource type=&quot;POOLED&quot;&gt;
        &lt;property name=&quot;driver&quot; value=&quot;${driver}&quot;/&gt;
        &lt;property name=&quot;url&quot; value=&quot;${url}&quot;/&gt;
        &lt;property name=&quot;username&quot; value=&quot;${username}&quot;/&gt;
        &lt;property name=&quot;password&quot; value=&quot;${password}&quot;/&gt;
      &lt;/dataSource&gt;
    &lt;/environment&gt;
  &lt;/environments&gt;
  &lt;mappers&gt;
    &lt;mapper resource=&quot;org/mybatis/example/BlogMapper.xml&quot;/&gt;
  &lt;/mappers&gt;
&lt;/configuration&gt;
</code></pre>
<p><strong>mybatis mapper&#x6587;&#x4EF6;&#x6620;&#x5C04;</strong></p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- &#x4F7F;&#x7528;&#x76F8;&#x5BF9;&#x4E8E;&#x7C7B;&#x8DEF;&#x5F84;&#x7684;&#x8D44;&#x6E90;&#x5F15;&#x7528; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">mappers</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">mapper</span> <span class="hljs-attr">resource</span>=<span class="hljs-string">&quot;org/mybatis/builder/AuthorMapper.xml&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">mappers</span>&gt;</span>
</code></pre>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- &#x4F7F;&#x7528;&#x6620;&#x5C04;&#x5668;&#x63A5;&#x53E3;&#x5B9E;&#x73B0;&#x7C7B;&#x7684;&#x5B8C;&#x5168;&#x9650;&#x5B9A;&#x7C7B;&#x540D;
    mybais&#x53BB;&#x52A0;&#x8F7D;class&#x5BF9;&#x5E94;&#x7684;&#x63A5;&#x53E3;&#xFF0C;&#x7136;&#x540E;&#x8FD8;&#x4F1A;&#x53BB;&#x52A0;&#x8F7D;&#x8BE5;&#x63A5;&#x53E3;&#x540C;&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x540C;&#x540D;xml&#x6587;&#x4EF6; 
--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">mappers</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">mapper</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;org.mybatis.builder.AuthorMapper&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">mappers</span>&gt;</span>
</code></pre>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- &#x5C06;&#x5305;&#x5185;&#x7684;&#x6620;&#x5C04;&#x5668;&#x63A5;&#x53E3;&#x5B9E;&#x73B0;&#x5168;&#x90E8;&#x6CE8;&#x518C;&#x4E3A;&#x6620;&#x5C04;&#x5668;   
 &#x4F7F;&#x7528;package&#x5143;&#x7D20;&#x6279;&#x91CF;&#x6CE8;&#x518C;Mapper&#x63A5;&#x53E3;
  1.&#x5305;&#x540D;&#x548C;&#x63A5;&#x53E3;&#x6240;&#x5728;&#x7684;&#x5305;&#x540D;&#x5B57;&#x4E00;&#x81F4;
  2.mapper&#x6587;&#x4EF6;&#x7684;&#x540D;&#x5B57;&#x548C;&#x63A5;&#x53E3;&#x7684;&#x540D;&#x5B57;&#x4E00;&#x81F4;
  3.&#x521B;&#x5EFA;&#x5305;&#x662F;&#x4F7F;&#x7528;/&#x5206;&#x5272;
--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">mappers</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">package</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;org.mybatis.builder&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">mappers</span>&gt;</span>
</code></pre>
<p><strong>&#x8BBE;&#x7F6E;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</strong></p>
<p>Maven<code>&#x4E2D;&#x9ED8;&#x8BA4;&#x662F;&#x53EA;&#x4F1A;&#x6253;&#x5305;</code>resource<code>&#x4E0B;&#x7684;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7684;&#x6587;&#x4EF6;&#x4E0D;&#x653E;&#x5728;</code>resource<code>&#xFF0C; &#x5219;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x544A;&#x77E5;</code>Maven</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">resources</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">resource</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">directory</span>&gt;</span>src/main/java<span class="hljs-tag">&lt;/<span class="hljs-name">directory</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">includes</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">include</span>&gt;</span>**/*.properties<span class="hljs-tag">&lt;/<span class="hljs-name">include</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">include</span>&gt;</span>**/*.xml<span class="hljs-tag">&lt;/<span class="hljs-name">include</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">includes</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">filtering</span>&gt;</span>false<span class="hljs-tag">&lt;/<span class="hljs-name">filtering</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">resource</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">resource</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">directory</span>&gt;</span>src/main/resources<span class="hljs-tag">&lt;/<span class="hljs-name">directory</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">includes</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">include</span>&gt;</span>**/*.properties<span class="hljs-tag">&lt;/<span class="hljs-name">include</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">include</span>&gt;</span>**/*.xml<span class="hljs-tag">&lt;/<span class="hljs-name">include</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">include</span>&gt;</span>**/*.tld<span class="hljs-tag">&lt;/<span class="hljs-name">include</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">includes</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">filtering</span>&gt;</span>false<span class="hljs-tag">&lt;/<span class="hljs-name">filtering</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">resource</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">resources</span>&gt;</span>
</code></pre>
<h3 id="2sql&#x6620;&#x5C04;&#x6587;&#x4EF6;">2.Sql&#x6620;&#x5C04;&#x6587;&#x4EF6;</h3>
<p>Mybatis&#x4E2D;&#x6240;&#x6709;&#x6570;&#x636E;&#x5E93;&#x7684;&#x64CD;&#x4F5C;&#x90FD;&#x4F1A;&#x57FA;&#x4E8E;&#x8BE5;&#x6620;&#x5C04;&#x6587;&#x4EF6;&#x548C;&#x914D;&#x7F6E;&#x7684;sql&#x8BED;&#x53E5;&#xFF0C;&#x5728;&#x8FD9;&#x4E2A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x4EFB;&#x4F55;&#x7C7B;&#x578B;&#x7684;sql&#x8BED;&#x53E5;&#x3002;&#x6846;&#x67B6;&#x4F1A;&#x6839;&#x636E;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x914D;&#x7F6E;&#xFF0C;&#x5B8C;&#x6210;&#x5BF9;sql&#x8BED;&#x53E5;&#x4EE5;&#x53CA;&#x8F93;&#x5165;&#x8F93;&#x51FA;&#x53C2;&#x6570;&#x7684;&#x6620;&#x5C04;&#x914D;&#x7F6E;&#x3002;</p>
<p>Mapper.xml&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x5927;&#x81F4;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-java">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;!DOCTYPE mapper PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; &quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot; &gt;
&lt;mapper namespace=&quot;&#x547D;&#x540D;&#x7A7A;&#x95F4;&quot;&gt;

&lt;select id=&quot;&#x65B9;&#x6CD5;&#x540D;&quot; resultMap=&quot;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&quot; parameterType=&quot;&#x53C2;&#x6570;&#x7C7B;&#x578B;&quot;&gt;

-- sql&#x8BED;&#x53E5;

&lt;/select&gt;

&lt;/mapper&gt;
</code></pre>
<h3 id="3&#x4F1A;&#x8BDD;&#x5DE5;&#x5382;&#x4E0E;&#x4F1A;&#x8BDD;">3.&#x4F1A;&#x8BDD;&#x5DE5;&#x5382;&#x4E0E;&#x4F1A;&#x8BDD;</h3>
<p>Mybatis&#x4E2D;&#x4F1A;&#x8BDD;&#x5DE5;&#x5382;SqlSessionFactory&#x7C7B;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x52A0;&#x8F7D;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#xFF0C;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x6E90;&#x914D;&#x7F6E;MapConfig.xml&#x4FE1;&#x606F;&#xFF0C;&#x4ECE;&#x800C;&#x4EA7;&#x751F;&#x4E00;&#x79CD;&#x53EF;&#x4EE5;&#x4E0E;&#x6570;&#x636E;&#x5E93;&#x4EA4;&#x4E92;&#x7684;&#x4F1A;&#x8BDD;&#x5B9E;&#x4F8B;SqlSession&#xFF0C;&#x4F1A;&#x8BDD;&#x5B9E;&#x4F8B;SqlSession&#x6839;&#x636E;Mapper.xml&#x6587;&#x4EF6;&#x4E2D;&#x914D;&#x7F6E;&#x7684;sql,&#x5BF9;&#x6570;&#x636E;&#x5E93;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;&#x3002;</p>
<h3 id="4&#x8FD0;&#x884C;&#x6D41;&#x7A0B;">4.&#x8FD0;&#x884C;&#x6D41;&#x7A0B;</h3>
<p>&#x4F1A;&#x8BDD;&#x5DE5;&#x5382;SqlSessionFactory&#x901A;&#x8FC7;&#x52A0;&#x8F7D;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x83B7;&#x53D6;MapConfig.xml&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4FE1;&#x606F;&#xFF0C;&#x7136;&#x540E;&#x751F;&#x6210;&#x53EF;&#x4EE5;&#x4E0E;&#x6570;&#x636E;&#x5E93;&#x4EA4;&#x4E92;&#x7684;&#x4F1A;&#x8BDD;&#x5B9E;&#x4F8B;SqlSession&#x3002;&#x4F1A;&#x8BDD;&#x5B9E;&#x4F8B;&#x53EF;&#x4EE5;&#x6839;&#x636E;Mapper&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x7684;Sql&#x914D;&#x7F6E;&#x53BB;&#x6267;&#x884C;&#x76F8;&#x5E94;&#x7684;&#x589E;&#x5220;&#x6539;&#x67E5;&#x64CD;&#x4F5C;</p>
<p>&#x6267;&#x884C;&#x6D41;&#x7A0B;&#x56FE;&#xFF1A;</p>
<p><img src="Mybatis&#x6846;&#x67B6;.assets/&#x6267;&#x884C;&#x6D41;&#x7A0B;.png" alt="&#x6267;&#x884C;&#x6D41;&#x7A0B;"></p>
<h2 id="mybatis&#x5B9E;&#x73B0;&#x589E;&#x5220;&#x6539;&#x67E5;">mybatis&#x5B9E;&#x73B0;&#x589E;&#x5220;&#x6539;&#x67E5;</h2>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestStudent</span> </span>{

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test01</span><span class="hljs-params">()</span></span>{

        <span class="hljs-keyword">try</span> {<span class="hljs-comment">//&#x52A0;&#x8F7D;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</span>
            InputStream in = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            <span class="hljs-comment">//&#x83B7;&#x53D6;sqlSession&#x5BF9;&#x8C61;</span>
            SqlSession sqlSession = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(in).openSession();
            <span class="hljs-comment">//&#x67E5;&#x8BE2;&#x6240;&#x6709;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>
        List&lt;Student&gt; students = sqlSession.selectList(<span class="hljs-string">&quot;cn.kgc.mybatis.dao.StudentDao.getAll&quot;</span>);    
            students.forEach(student -&gt; System.out.println(student) );
        } <span class="hljs-keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }
    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test02</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x67E5;&#x8BE2;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>

        <span class="hljs-keyword">try</span> {<span class="hljs-comment">//&#x52A0;&#x8F7D;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</span>
            InputStream in = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            <span class="hljs-comment">//&#x83B7;&#x53D6;sqlSession&#x5BF9;&#x8C61;</span>
            SqlSession sqlSession = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(in).openSession();
            <span class="hljs-comment">//&#x6839;&#x636E;&#x7528;&#x6237;&#x540D;&#x67E5;&#x8BE2;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>
            Student student = sqlSession.selectOne(<span class="hljs-string">&quot;cn.kgc.mybatis.dao.StudentDao.findOne&quot;</span>,<span class="hljs-string">&quot;tom&quot;</span>);
            System.out.println(student);
            sqlSession.close();
        } <span class="hljs-keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }
    }
    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test03</span><span class="hljs-params">()</span> </span>{<span class="hljs-comment">//&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>

        <span class="hljs-keyword">try</span> {<span class="hljs-comment">//&#x52A0;&#x8F7D;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</span>
            InputStream in = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            <span class="hljs-comment">//&#x83B7;&#x53D6;sqlSession&#x5BF9;&#x8C61;</span>
            SqlSession sqlSession = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(in).openSession();
            <span class="hljs-comment">//&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>
            Student student = Student.builder().stuBirth(<span class="hljs-keyword">new</span> Date()).stuName(<span class="hljs-string">&quot;lilei&quot;</span>).stuNo(<span class="hljs-string">&quot;2021073001&quot;</span>).stuSex(<span class="hljs-string">&quot;&#x7537;&quot;</span>).build();
            <span class="hljs-keyword">int</span> i = sqlSession.insert(<span class="hljs-string">&quot;cn.kgc.mybatis.dao.StudentDao.addOne&quot;</span>, student);
            System.out.println(i);
            sqlSession.commit();
            sqlSession.close();

        } <span class="hljs-keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }

    }
    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test04</span><span class="hljs-params">()</span> </span>{<span class="hljs-comment">//&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>

        <span class="hljs-keyword">try</span>{
            InputStream in = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            <span class="hljs-comment">//&#x83B7;&#x53D6;sqlSession&#x5BF9;&#x8C61; &#x540C;&#x65F6;&#x53EF;&#x8BBE;&#x7F6E;&#x4E8B;&#x52A1;&#x7684;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;  openSession(true)</span>
            SqlSession sqlSession = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(in).openSession();
            <span class="hljs-keyword">int</span> delete = sqlSession.delete(<span class="hljs-string">&quot;cn.kgc.mybatis.dao.StudentDao.delOne&quot;</span>,<span class="hljs-string">&quot;lilei&quot;</span> );
            sqlSession.commit();
            sqlSession.close();
            System.out.println(delete);
        }<span class="hljs-keyword">catch</span> (Exception e){
            e.printStackTrace();
        }

    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test05</span><span class="hljs-params">()</span> </span>{<span class="hljs-comment">//&#x4FEE;&#x6539;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F;</span>

        <span class="hljs-keyword">try</span>{
            InputStream in = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            <span class="hljs-comment">//&#x83B7;&#x53D6;sqlSession&#x5BF9;&#x8C61;</span>
            SqlSession sqlSession = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(in).openSession();

            Student student = Student.builder().stuBirth(<span class="hljs-keyword">new</span> Date()).stuName(<span class="hljs-string">&quot;lili&quot;</span>).stuNo(<span class="hljs-string">&quot;2021073001&quot;</span>).stuSex(<span class="hljs-string">&quot;&#x5973;&quot;</span>).build();
            <span class="hljs-keyword">int</span> delete = sqlSession.update(<span class="hljs-string">&quot;cn.kgc.mybatis.dao.StudentDao.updateStudent&quot;</span>,student);
            sqlSession.commit();
            sqlSession.close();
            System.out.println(delete);
        }<span class="hljs-keyword">catch</span> (Exception e){
            e.printStackTrace();
        }


    }

}
</code></pre>
<p><strong>mybatis&#x4E2D;&#x4F7F;&#x7528;log4j&#x65E5;&#x5FD7;&#x5DE5;&#x5177;</strong></p>
<p>1.&#x914D;&#x7F6E;mybatis-config.xml</p>
<pre><code class="lang-java">&lt;!--    &#x5F00;&#x542F;&#x65E5;&#x5FD7;--&gt;
 &lt;setting name=<span class="hljs-string">&quot;logImpl&quot;</span> value=<span class="hljs-string">&quot;LOG4J&quot;</span>/&gt;
</code></pre>
<p>&#x5F00;&#x542F;&#x9A7C;&#x5CF0;&#x547D;&#x540D;</p>
<pre><code class="lang-java">&lt;!--    &#x8BBE;&#x7F6E;&#x9A7C;&#x5CF0;&#x547D;&#x540D;--&gt;
 &lt;setting name=<span class="hljs-string">&quot;mapUnderscoreToCamelCase&quot;</span> value=<span class="hljs-string">&quot;true&quot;</span>/&gt;
</code></pre>
<p>&#x8BBE;&#x7F6E;&#x522B;&#x540D;</p>
<pre><code class="lang-java">&lt;typeAliases&gt;
    &lt;!--&#x8BBE;&#x7F6E;&#x522B;&#x540D;--&gt;
    &lt;package name=&quot;cn.kgc.mybatis.pojo&quot;/&gt;
&lt;/typeAliases&gt;
</code></pre>
<p>2.&#x914D;&#x7F6E;log4j.properties&#x6587;&#x4EF6;&#xFF0C;&#x653E;&#x7F6E;&#x5728;resources&#x76EE;&#x5F55;&#x4E0B;</p>
<pre><code class="lang-properties">log4j.rootLogger=DEBUG,Console

#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Target=System.out
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n

log4j.logger.org.apache=ERROR
log4j.logger.org.mybatis=ERROR
log4j.logger.org.springframework=ERROR

#&#x8FD9;&#x4E2A;&#x9700;&#x8981;
log4j.logger.log4jdbc.debug=ERROR
log4j.logger.com.gk.mapper=ERROR
log4j.logger.jdbc.audit=ERROR
log4j.logger.jdbc.resultset=ERROR
#&#x8FD9;&#x4E2A;&#x6253;&#x5370;SQL&#x8BED;&#x53E5;&#x975E;&#x5E38;&#x91CD;&#x8981;
log4j.logger.jdbc.sqlonly=DEBUG
log4j.logger.jdbc.sqltiming=ERROR
log4j.logger.jdbc.connection=FATAL
</code></pre>
<p><strong>&#x4F7F;&#x7528;mapper&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x5B9E;&#x73B0;&#x589E;&#x5220;&#x6539;&#x67E5;</strong></p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestStudentMapper</span> </span>{
    SqlSessionFactory factory;
    <span class="hljs-meta">@Before</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span></span>{
        <span class="hljs-keyword">try</span> {
            InputStream  in = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            SqlSessionFactoryBuilder sfb = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder();
            factory = sfb.build(in);
        } <span class="hljs-keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }


    }
    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test01</span><span class="hljs-params">()</span></span>{
            <span class="hljs-comment">//&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;</span>
            SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
            <span class="hljs-comment">//&#x83B7;&#x53D6;dao&#x5C42;&#x7684;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;</span>
            StudentDao studentDao = sqlSession.getMapper(StudentDao.class);
            List&lt;Student&gt; students = studentDao.getAll();
            students.forEach(student -&gt; System.out.println(student));
    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test02</span><span class="hljs-params">()</span></span>{ <span class="hljs-comment">//&#x6DFB;&#x52A0;&#x6570;&#x636E;</span>

        SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
        Student student = Student.builder().stuSex(<span class="hljs-string">&quot;&#x7537;&quot;</span>).stuNo(<span class="hljs-string">&quot;2021073100&quot;</span>).stuName(<span class="hljs-string">&quot;&#x674E;&#x56DB;&quot;</span>).stuBirth(<span class="hljs-keyword">new</span> Date()).build();
        StudentDao studentDao = sqlSession.getMapper(StudentDao.class);
        Integer line = studentDao.addOne(student);
        System.out.println(line);
    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span>  <span class="hljs-keyword">void</span> <span class="hljs-title">test03</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x5220;&#x9664;&#x4E00;&#x6761;&#x6570;&#x636E;</span>
        SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
        StudentDao studentDao = sqlSession.getMapper(StudentDao.class);
        Integer line = studentDao.delOne(<span class="hljs-string">&quot;&#x674E;&#x56DB;&quot;</span>);
        System.out.println(line);
    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test04</span><span class="hljs-params">()</span> </span>{ <span class="hljs-comment">//&#x4FEE;&#x6539;&#x6570;&#x636E;</span>
        SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
        StudentDao studentDao = sqlSession.getMapper(StudentDao.class);
        Student student = Student.builder().stuSex(<span class="hljs-string">&quot;&#x5973;&quot;</span>).stuNo(<span class="hljs-string">&quot;2021073100&quot;</span>).stuName(<span class="hljs-string">&quot;&#x674E;&#x56DB;&quot;</span>).stuBirth(<span class="hljs-keyword">new</span> Date()).build();
        Integer line = studentDao.updateOne(student);
        System.out.println(line);

    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test06</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F; &#x4E00;&#x4E2A;&#x53C2;&#x6570;</span>
        SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
        StudentDao studentDao = sqlSession.getMapper(StudentDao.class);

        List&lt;Student&gt; students = studentDao.selectLikeName(<span class="hljs-string">&quot;li&quot;</span>);
        System.out.println(students.toString());

    }

    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test07</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F; &#x4E24;&#x4E2A;&#x53C2;&#x6570;</span>
        SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
        StudentDao studentDao = sqlSession.getMapper(StudentDao.class);

        List&lt;Student&gt; students = studentDao.selectLikeName2(<span class="hljs-string">&quot;li&quot;</span>, <span class="hljs-string">&quot;2021072902&quot;</span>);
        System.out.println(students.toString());


    }
     <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test08</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;&#x4E00;&#x4E2A;&#x5B66;&#x751F;&#x4FE1;&#x606F; &#x4E00;&#x4E2A;&#x96C6;&#x5408;&#x53C2;&#x6570;  mapper&#x6587;&#x4EF6;&#x4E2D;&#x6309;&#x7167;key&#x53D6;&#x503C;</span>
        SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
        StudentDao studentDao = sqlSession.getMapper(StudentDao.class);

        HashMap&lt;String, String&gt; map = <span class="hljs-keyword">new</span> HashMap&lt;&gt;();
        map.put(<span class="hljs-string">&quot;stuname&quot;</span>,<span class="hljs-string">&quot;li&quot;</span>);
        map.put(<span class="hljs-string">&quot;stuno&quot;</span>, <span class="hljs-string">&quot;2021072902&quot;</span>);
        List&lt;Student&gt; students = studentDao.selectLikeName3(map);
        System.out.println(students.toString());
    }

}
</code></pre>
<h2 id="mybatis&#x7684;&#x83B7;&#x53D6;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x5F0F;"><strong>Mybatis&#x7684;&#x83B7;&#x53D6;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x5F0F;</strong></h2>
<p>&#x65B9;&#x5F0F;1&#xFF1A;${}  &#x5B57;&#x7B26;&#x4E32;&#x62FC;&#x63A5;</p>
<p>&#x65B9;&#x5F0F;2&#xFF1A;#{}  &#x5360;&#x4F4D;&#x7B26;</p>
<p><strong>1.Mapper&#x63A5;&#x53E3;&#x53C2;&#x6570;&#x4E3A;&#x5355;&#x4E2A;&#x53C2;&#x6570;</strong></p>
<pre><code class="lang-sql"> &lt;delete id=&quot;delUserById&quot; parameterType=&quot;int&quot;&gt;
        delete from user where id = #{id}
 &lt;/delete&gt;

  &lt;delete id=&quot;delUserById&quot; parameterType=&quot;int&quot;&gt;
        delete from user where id = ${id}
 &lt;/delete&gt;

 &#x6CE8;&#xFF1A;&#x5982;&#x4F55;&#x53C2;&#x6570;&#x662F;String&#x7C7B;&#x578B;&#x4F7F;&#x7528;${}&#x83B7;&#x53D6;&#x53C2;&#x6570;&#x662F;&#x9700;&#x8981;&#x624B;&#x52A8;&#x6DFB;&#x52A0;&#x5F15;&#x53F7; &apos;&apos;
</code></pre>
<p><strong>2.Mapper&#x63A5;&#x53E3;&#x53C2;&#x6570;&#x662F;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x83B7;&#x53D6;</strong></p>
<p>mybatis&#x5728;&#x5904;&#x7406;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x65F6;,&#x4F1A;&#x5C06;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x4FDD;&#x5B58;&#x5230;map&#x96C6;&#x5408;&#x4E2D;&#x4F1A; &#x4EE5; agr0 &#xFF0C;agr1&#x6216;param1 param2&#x4E3A;&#x952E; &#x4EE5;&#x53C2;&#x6570;&#x4F4D;&#x7F6E;&#x8FDB;&#x884C;&#x5B58;&#x50A8;</p>
<pre><code class="lang-java"><span class="hljs-function">User <span class="hljs-title">selectUserByUserNameAndPassword</span><span class="hljs-params">(String username,String password)</span></span>;
</code></pre>
<pre><code class="lang-mysql"> &lt;select id=&quot;selectUserByUserNameAndPassword&quot; resultType=&quot;user&quot;&gt;
        select  * from user where user_name = #{arg0} and password = #{arg1}
 &lt;/select&gt;
</code></pre>
<p><strong>3.&#x5C06;&#x53C2;&#x6570;&#x8BBE;&#x4E3A;map&#x96C6;&#x5408;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x7684;&#x4F20;&#x9012;</strong></p>
<pre><code class="lang-java"><span class="hljs-function">User <span class="hljs-title">selectUserByMap</span><span class="hljs-params">(Map map)</span></span>;
</code></pre>
<pre><code class="lang-mysql">&lt;select id=&quot;selectUserByMap&quot; resultType=&quot;cn.kgc.mybatis.entity.User&quot;&gt;
        select  * from user where user_name = #{username} and password = #{password}
&lt;/select&gt;
</code></pre>
<p><strong>4.&#x901A;&#x8FC7;&#x6CE8;&#x89E3;@param(&quot;&#x952E;&#x540D;&quot;)&#x8BBE;&#x7F6E;&#x53C2;&#x6570;&#x7684;&#x83B7;&#x53D6;&#x540D;&#x5B57;</strong></p>
<pre><code class="lang-java"><span class="hljs-function">User <span class="hljs-title">selectUserByUserNameAndPassword</span><span class="hljs-params">(@param(<span class="hljs-string">&quot;username&quot;</span>)</span>String username,<span class="hljs-params">(@param(<span class="hljs-string">&quot;password&quot;</span>)</span>String password)</span>;
</code></pre>
<pre><code class="lang-mysql">&lt;select id=&quot;selectUserByUserNameAndPassword&quot; resultType=&quot;user&quot;&gt;
        select  * from user where user_name = #{username} and password = #{password}
&lt;/select&gt;

&#x6216;&#x8005;

&lt;select id=&quot;selectUserByUserNameAndPassword&quot; resultType=&quot;user&quot;&gt;
        select  * from user where user_name = #{param1} and password = #{param2}
&lt;/select&gt;
</code></pre>
<p><strong>5.&#x5C06;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x8BBE;&#x7F6E;&#x6210;&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x7684;&#x4F20;&#x9012;</strong></p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">insertUser</span><span class="hljs-params">(User user)</span></span>;
</code></pre>
<pre><code class="lang-mysql"> &lt;insert id=&quot;insertUser&quot; parameterType=&quot;user&quot; useGeneratedKeys=&quot;true&quot; keyProperty=&quot;id&quot; &gt;
         insert into user values ( #{id},#{userName},#{password})
 &lt;/insert&gt;
</code></pre>
<p><strong>Mybatis&#x4E2D;&#x7684;&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;</strong></p>
<p>&#x65B9;&#x5F0F;1&#xFF1A;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> tableName <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">name</span> <span class="hljs-keyword">LIKE</span> #{<span class="hljs-built_in">text</span>}

<span class="hljs-comment">-- &#x4F20;&#x9012;&#x7684;&#x53C2;&#x6570;&#x9700;&#x8981;&#x62FC;&#x63A5;  &#x2018;%text%&#x2019;</span>
</code></pre>
<p>&#x65B9;&#x5F0F;2&#xFF1A;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> tableName <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">name</span> <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&apos;%${text}%&apos;</span>;
 <span class="hljs-comment">-- &#x4F7F;&#x7528;$&#x66FF;&#x4EE3;# &#x53C2;&#x6570;&#x65E0;&#x9700;&#x5728;&#x62FC;&#x63A5;%  &#x5B58;&#x5728;sql&#x6CE8;&#x5165;</span>
</code></pre>
<p>&#x65B9;&#x5F0F;3</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> tableName <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">name</span> <span class="hljs-keyword">LIKE</span> <span class="hljs-keyword">CONCAT</span>(<span class="hljs-string">&apos;%&apos;</span>, #{<span class="hljs-built_in">text</span>}), <span class="hljs-string">&apos;%&apos;</span>);
<span class="hljs-comment">-- &#x4F7F;&#x7528;mysql&#x7684;&#x51FD;&#x6570;  &#x5B9E;&#x73B0;&#x62FC;&#x63A5;</span>
</code></pre>
<p><strong>6.&#x6279;&#x91CF;&#x5220;&#x9664;</strong></p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">deleteMore</span><span class="hljs-params">(String ids)</span></span>;
</code></pre>
<pre><code class="lang-mysql">  &lt;delete id=&quot;deleteMore&quot;&gt;
        delete from user where id in(${ids})
   &lt;/delete&gt;
</code></pre>
<h2 id="mapper&#x4E2D;&#x81EA;&#x5B9A;&#x4E49;&#x6620;&#x5C04;"><strong>mapper&#x4E2D;&#x81EA;&#x5B9A;&#x4E49;&#x6620;&#x5C04;</strong></h2>
<p>&#x81EA;&#x5B9A;&#x4E49;&#x6620;&#x5C04;&#x7684;&#x7528;&#x6CD5;&#x4E4B;&#x4E00;&#xFF0C;&#x89E3;&#x51B3;&#x8868;&#x683C;&#x67E5;&#x8BE2;&#x7684;&#x5B57;&#x6BB5;&#x540D;&#x548C;&#x5B9E;&#x4F53;&#x7C7B;&#x4E2D;&#x4E0D;&#x4E00;&#x81F4;&#x7684;&#x60C5;&#x51B5;</p>
<pre><code class="lang-mysql">&lt;resultMap id=&quot;userMap&quot; type=&quot;user&quot;&gt;
        &lt;id column=&quot;id&quot; property=&quot;id&quot;&gt;&lt;/id&gt;
        &lt;result column=&quot;user_name&quot; property=&quot;userName&quot;&gt;&lt;/result&gt;
        &lt;result column=&quot;password&quot; property=&quot;password&quot;&gt;&lt;/result&gt;
&lt;/resultMap&gt;
</code></pre>
<p><strong>mybatis&#x5BF9;&#x8C61;&#x7684;&#x5173;&#x8054;&#x5173;&#x7CFB;</strong></p>
<p><strong>&#x4E00;&#x5BF9;&#x591A;&#x5173;&#x7CFB;&#x5904;&#x7406;(&#x4E00;&#x65B9;)</strong></p>
<pre><code class="lang-mysql">&lt;resultMap id=&quot;selectByEIdMap&quot; type=&quot;cn.kgc.mybatis.entity.Emp&quot;&gt;
        &lt;result column=&quot;id&quot; property=&quot;dept.id&quot; &gt;&lt;/result&gt;
        &lt;result column=&quot;dname&quot; property=&quot;dept.dName&quot;&gt;&lt;/result&gt;
 &lt;/resultMap&gt;


    &lt;resultMap id=&quot;selectByEIdMap2&quot; type=&quot;cn.kgc.mybatis.entity.Emp&quot;&gt;
        &lt;id column=&quot;eid&quot; property=&quot;eId&quot;&gt;&lt;/id&gt;
        &lt;result column=&quot;ename&quot; property=&quot;EName&quot;&gt;&lt;/result&gt;
        &lt;result column=&quot;age&quot; property=&quot;age&quot;&gt;&lt;/result&gt;
        &lt;result column=&quot;deptno&quot; property=&quot;deptNo&quot;&gt;&lt;/result&gt;
        &lt;!--&#x5B9E;&#x4F53;&#x5BF9;&#x8C61;&#x6807;&#x8BC6;--&gt;
       &lt;association property=&quot;dept&quot; javaType=&quot;dept&quot;&gt;
           &lt;id column=&quot;id&quot; property=&quot;id&quot;&gt;&lt;/id&gt;
           &lt;result column=&quot;dname&quot; property=&quot;dName&quot;&gt;&lt;/result&gt;
       &lt;/association&gt;
    &lt;/resultMap&gt;

    &lt;!-- &#x5206;&#x6B65;&#x67E5;&#x8BE2; --&gt;
    &lt;resultMap id=&quot;selectByEIdMap3&quot; type=&quot;cn.kgc.mybatis.entity.Emp&quot;&gt;
        &lt;id column=&quot;eid&quot; property=&quot;eId&quot;&gt;&lt;/id&gt;
        &lt;result column=&quot;ename&quot; property=&quot;EName&quot;&gt;&lt;/result&gt;
        &lt;result column=&quot;age&quot; property=&quot;age&quot;&gt;&lt;/result&gt;
        &lt;result column=&quot;deptno&quot; property=&quot;deptNo&quot;&gt;&lt;/result&gt;
        &lt;association property=&quot;dept&quot; select=&quot;cn.kgc.mybatis.mapper.DeptMapper.selectById&quot; 
                                    column=&quot;deptno&quot; 
                                    fetchType=&quot;eager&quot;&gt;
        &lt;/association&gt;
    &lt;/resultMap&gt;

&#x6CE8;&#xFF1A;&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x8BBE;&#x7F6E;  &#xFF1A;
        1. &lt;setting name=&quot;lazyLoadingEnabled&quot; value=&quot;true&quot;/&gt; 
        2. &lt;setting name=&quot;aggressiveLazyLoading&quot; value=&quot;false&quot;/&gt;  3.4.1&#x4E4B;&#x524D;&#x7684;&#x7248;&#x672C;&#x9700;&#x8981;&#x8BBE;&#x7F6E;

    &lt;select id=&quot;selectByEId&quot; resultMap=&quot;selectByEIdMap2&quot;&gt;
            select  * from emp left  join  dept on  emp.deptno = dept.id  where eid = #{eid}
    &lt;/select&gt;

    &lt;select id=&quot;selectByEId2&quot; resultMap=&quot;selectByEIdMap3&quot;&gt;
            select  * from emp  where eid = #{eid}
    &lt;/select&gt;
</code></pre>
<p><strong>&#x4E00;&#x5BF9;&#x591A;&#x5173;&#x7CFB;&#x5904;&#x7406;(&#x591A;&#x65B9;)</strong></p>
<pre><code class="lang-mysql"> &lt;resultMap id=&quot;BaseResultMap&quot; type=&quot;cn.kgc.mybatis.entity.Dept&quot;&gt;
            &lt;id property=&quot;id&quot; column=&quot;id&quot; /&gt;
            &lt;result property=&quot;dName&quot; column=&quot;dname&quot; /&gt;
            &lt;collection property=&quot;emps&quot; ofType=&quot;emp&quot;&gt;
                &lt;id column=&quot;eid&quot; property=&quot;eId&quot;&gt;&lt;/id&gt;
                &lt;result column=&quot;ename&quot; property=&quot;EName&quot;&gt;&lt;/result&gt;
                &lt;result column=&quot;age&quot; property=&quot;age&quot;&gt;&lt;/result&gt;
                &lt;result column=&quot;deptno&quot; property=&quot;deptNo&quot;&gt;&lt;/result&gt;
            &lt;/collection&gt;
    &lt;/resultMap&gt;


    &lt;resultMap id=&quot;BaseResultMap2&quot; type=&quot;cn.kgc.mybatis.entity.Dept&quot;&gt;
        &lt;id property=&quot;id&quot; column=&quot;id&quot; /&gt;
        &lt;result property=&quot;dName&quot; column=&quot;dname&quot; /&gt;
        &lt;collection property=&quot;emps&quot; select=&quot;cn.kgc.mybatis.mapper.EmpMapper.selectByDeptId&quot; column=&quot;id&quot;&gt;&lt;/collection&gt;
    &lt;/resultMap&gt;

    &lt;select id=&quot;selectById&quot; resultType=&quot;dept&quot;&gt;
        select  * from dept where id = #{id}
    &lt;/select&gt;

    &lt;select id=&quot;selectById2&quot; resultMap=&quot;BaseResultMap&quot;&gt;
        select emp.* ,dept.* from dept left join emp on dept.id = emp.deptno where id = #{id}
    &lt;/select&gt;

    &lt;select id=&quot;selectById3&quot; resultMap=&quot;BaseResultMap2&quot;&gt;
        select dept.* from dept  where id = #{id}
    &lt;/select&gt;
</code></pre>
<h2 id="mybatis&#x52A8;&#x6001;sql">mybatis&#x52A8;&#x6001;sql</h2>
<p>&#x52A8;&#x6001; SQL &#x662F; MyBatis &#x7684;&#x5F3A;&#x5927;&#x7279;&#x6027;&#x4E4B;&#x4E00;&#x3002;&#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528;&#x8FC7; JDBC &#x6216;&#x5176;&#x5B83;&#x7C7B;&#x4F3C;&#x7684;&#x6846;&#x67B6;&#xFF0C;&#x4F60;&#x5E94;&#x8BE5;&#x80FD;&#x7406;&#x89E3;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x6761;&#x4EF6;&#x62FC;&#x63A5; SQL &#x8BED;&#x53E5;&#x6709;&#x591A;&#x75DB;&#x82E6;&#xFF0C;&#x4F8B;&#x5982;&#x62FC;&#x63A5;&#x65F6;&#x8981;&#x786E;&#x4FDD;&#x4E0D;&#x80FD;&#x5FD8;&#x8BB0;&#x6DFB;&#x52A0;&#x5FC5;&#x8981;&#x7684;&#x7A7A;&#x683C;&#xFF0C;&#x8FD8;&#x8981;&#x6CE8;&#x610F;&#x53BB;&#x6389;&#x5217;&#x8868;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5217;&#x540D;&#x7684;&#x9017;&#x53F7;&#x3002;&#x5229;&#x7528;&#x52A8;&#x6001; SQL&#xFF0C;&#x53EF;&#x4EE5;&#x5F7B;&#x5E95;&#x6446;&#x8131;&#x8FD9;&#x79CD;&#x75DB;&#x82E6;</p>
<blockquote>
<h4 id="&#x52A8;&#x6001;sqlif-&#x8BED;&#x53E5;">&#x52A8;&#x6001;SQL:if &#x8BED;&#x53E5;</h4>
</blockquote>
<p>&#x6839;&#x636E; stu_name &#x548C; stu_sex &#x6765;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#x3002;&#x5982;&#x679C;stu_name&#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48;&#x5C06;&#x53EA;&#x6839;&#x636E;stu_sex&#x6765;&#x67E5;&#x8BE2;&#xFF1B;&#x53CD;&#x4E4B;&#x53EA;&#x6839;&#x636E;stu_name&#x6765;&#x67E5;&#x8BE2;</p>
<p>&#x9996;&#x5148;&#x4E0D;&#x4F7F;&#x7528; &#x52A8;&#x6001;SQL &#x6765;&#x4E66;&#x5199;</p>
<pre><code class="lang-java">&lt;select id=&quot;selectStudent&quot; resultType=&quot;student&quot; parameterType=&quot;cn.kgc.mybatis.pojo.Student&quot;&gt;
    select * from user where stu_name=#{stu_name} and stu_sex=#{stu_sex}
&lt;/select&gt;
</code></pre>
<p>&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x5982;&#x679C; #{stu_name} &#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x4E5F;&#x662F;&#x7A7A;&#xFF0C;&#x5982;&#x4F55;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x5462;&#xFF1F;&#x4F7F;&#x7528; if &#x6765;&#x5224;&#x65AD;</p>
<pre><code class="lang-java">&lt;select id=&quot;selectStudent&quot; resultType=&quot;student&quot; parameterType=&quot;cn.kgc.mybatis.pojo.Student&quot;&gt;
     select * from student where  
     &lt;if test=&quot;stu_name != null&quot;&gt;
               stu_name=#{stu_name}
     &lt;/if&gt;
    &lt;if test=&quot;stu_sex!= null&quot;&gt;
           and stu_sex=#{stu_sex}
    &lt;/if&gt;
&lt;/select&gt;
</code></pre>
<p>&#x3000;&#x8FD9;&#x6837;&#x5199;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x5982;&#x679C; sex &#x7B49;&#x4E8E; null&#xFF0C;&#x90A3;&#x4E48;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x4E3A; select <em> from student where stu_name=#{stu_name},&#x4F46;&#x662F;&#x5982;&#x679C;stu_name &#x4E3A;&#x7A7A;&#x5462;&#xFF1F;&#x90A3;&#x4E48;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x4E3A; select </em> from user where and stu_sex=#{sex}&#xFF0C;&#x8FD9;&#x662F;&#x9519;&#x8BEF;&#x7684; SQL &#x8BED;&#x53E5;&#xFF0C;&#x5982;&#x4F55;&#x89E3;&#x51B3;&#x5462;&#xFF1F;</p>
<blockquote>
<h4 id="ifwhere-&#x8BED;&#x53E5;">if+where &#x8BED;&#x53E5;</h4>
</blockquote>
<pre><code class="lang-java">&lt;select id=&quot;selectStudent&quot; resultType=&quot;student&quot; parameterType=&quot;cn.kgc.mybatis.pojo.Student&quot;&gt;
     select * from student 
        &lt;where&gt; 
                 &lt;if test=&quot;stu_name != null&quot;&gt;
                         stu_name=#{stu_name}
                 &lt;/if&gt;
                 &lt;if test=&quot;stu_sex!= null&quot;&gt;
                         and stu_sex=#{stu_sex}
                 &lt;/if&gt;
        &lt;/where&gt; 
&lt;/select&gt;
</code></pre>
<p>&#x8FD9;&#x4E2A;where&#x6807;&#x7B7E;&#x4F1A;&#x77E5;&#x9053;&#x5982;&#x679C;&#x5B83;&#x5305;&#x542B;&#x7684;&#x6807;&#x7B7E;&#x4E2D;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x8BDD;&#xFF0C;&#x5B83;&#x5C31;&#x63D2;&#x5165;&#x4E00;&#x4E2A;where&#x3002;&#x6B64;&#x5916;&#xFF0C;&#x5982;&#x679C;&#x6807;&#x7B7E;&#x8FD4;&#x56DE;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4EE5;AND &#x6216;OR &#x5F00;&#x5934;&#x7684;&#xFF0C;&#x5219;&#x5B83;&#x4F1A;&#x5254;&#x9664;&#x6389;</p>
<blockquote>
<h4 id="&#x52A8;&#x6001;sqlifset-&#x8BED;&#x53E5;">&#x52A8;&#x6001;SQL:if+set &#x8BED;&#x53E5;</h4>
</blockquote>
<p>&#x4E0A;&#x9762;&#x7684;&#x5BF9;&#x4E8E;&#x67E5;&#x8BE2; SQL &#x8BED;&#x53E5;&#x5305;&#x542B; where &#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5982;&#x679C;&#x5728;&#x8FDB;&#x884C;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x542B;&#x6709; set &#x5173;&#x952E;&#x8BCD;</p>
<pre><code class="lang-java">&lt;update id=&quot;updateStudentById&quot; parameterType=&quot;cn.kgc.mybatis.pojo.Student&quot;&gt;
    update student stu
        &lt;set&gt;
            &lt;if test=&quot;stuname != null and stuname != &apos;&apos;&quot;&gt;
                stu.stu_name = #{stuName},
            &lt;/if&gt;
            &lt;if test=&quot;stusex != null and stusex != &apos;&apos;&quot;&gt;
                stu.stu_sex = #{stuSex}
            &lt;/if&gt;
        &lt;/set&gt;
     where id=#{id}
&lt;/update&gt;
</code></pre>
<ul>
<li>&#x5982;&#x679C;&#x7B2C;&#x4E00;&#x4E2A;&#x6761;&#x4EF6; username &#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48; sql &#x8BED;&#x53E5;&#x4E3A;&#xFF1A;update user u set u.sex=? where id=?</li>
<li>&#x5982;&#x679C;&#x7B2C;&#x4E00;&#x4E2A;&#x6761;&#x4EF6;&#x4E0D;&#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48; sql &#x8BED;&#x53E5;&#x4E3A;&#xFF1A;update user u set u.username = ? ,u.sex = ? where id=?</li>
</ul>
<blockquote>
<h4 id="&#x52A8;&#x6001;sqlchoosewhenotherwise-&#x8BED;&#x53E5;">&#x52A8;&#x6001;SQL:choose(when,otherwise) &#x8BED;&#x53E5;</h4>
</blockquote>
<p>&#x6709;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x60F3;&#x7528;&#x5230;&#x6240;&#x6709;&#x7684;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#xFF0C;&#x53EA;&#x60F3;&#x9009;&#x62E9;&#x5176;&#x4E2D;&#x7684;&#x4E00;&#x4E2A;&#xFF0C;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#x6709;&#x4E00;&#x4E2A;&#x6EE1;&#x8DB3;&#x5373;&#x53EF;&#xFF0C;&#x4F7F;&#x7528; choose &#x6807;&#x7B7E;&#x53EF;&#x4EE5;&#x89E3;&#x51B3;&#x6B64;&#x7C7B;&#x95EE;&#x9898;&#xFF0C;&#x7C7B;&#x4F3C;&#x4E8E; Java &#x7684; switch &#x8BED;&#x53E5;</p>
<pre><code class="lang-java">&lt;select id=&quot;selectStudentByChoose&quot; resultType=&quot;com.ys.po.User&quot; parameterType=&quot;com.ys.po.User&quot;&gt;
      select * from student
      &lt;where&gt;
          &lt;choose&gt;
              &lt;when test=&quot;id !=&apos;&apos; and id != null&quot;&gt;
                  id=#{id}
              &lt;/when&gt;
              &lt;when test=&quot;username !=&apos;&apos; and username != null&quot;&gt;
                  and username=#{username}
              &lt;/when&gt;
              &lt;otherwise&gt;
                  and sex=#{sex}
              &lt;/otherwise&gt;
          &lt;/choose&gt;
      &lt;/where&gt;
 &lt;/select&gt;
</code></pre>
<p>&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x6709;&#x4E09;&#x4E2A;&#x6761;&#x4EF6;&#xFF0C;id,username,sex&#xFF0C;&#x53EA;&#x80FD;&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x4F5C;&#x4E3A;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;</p>
<ul>
<li>&#x5982;&#x679C; id &#x4E0D;&#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x4E3A;&#xFF1A;select * from user where  id=?</li>
<li>&#x5982;&#x679C; id &#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48;&#x770B;username &#x662F;&#x5426;&#x4E3A;&#x7A7A;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48;&#x8BED;&#x53E5;&#x4E3A; select * from user where username=?;</li>
<li>&#x5982;&#x679C; username &#x4E3A;&#x7A7A;&#xFF0C;&#x90A3;&#x4E48;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x4E3A; select * from user where sex=?</li>
</ul>
<blockquote>
<h4 id="&#x52A8;&#x6001;sqltrim-&#x8BED;&#x53E5;">&#x52A8;&#x6001;SQL:trim &#x8BED;&#x53E5;</h4>
</blockquote>
<p>trim&#x6807;&#x8BB0;&#x662F;&#x4E00;&#x4E2A;&#x683C;&#x5F0F;&#x5316;&#x7684;&#x6807;&#x8BB0;&#xFF0C;&#x53EF;&#x4EE5;&#x5B8C;&#x6210;set&#x6216;&#x8005;&#x662F;where&#x6807;&#x8BB0;&#x7684;&#x529F;&#x80FD;</p>
<p><strong>&#x7528; trim &#x6539;&#x5199;&#x4E0A;&#x9762;&#x7684; if+where &#x8BED;&#x53E5;</strong></p>
<pre><code class="lang-java">&lt;select id=&quot;selectStudent&quot; resultType=&quot;student&quot; parameterType=&quot;cn.kgc.mybatis.pojo.Student&quot;&gt;
     select * from user 
       &lt;trim prefix=&quot;where&quot; prefixOverrides=&quot; and | or&quot;&gt;
            &lt;if test=&quot;stu_name != null&quot;&gt;
                stu_name=#{stu_name}
             &lt;/if&gt;
            &lt;if test=&quot;stu_sex!= null&quot;&gt;
                and stu_sex=#{stu_sex}
            &lt;/if&gt;
       &lt;/trim&gt;
&lt;/select&gt;
</code></pre>
<ul>
<li>prefix&#xFF1A;&#x524D;&#x7F00;&#x3000;&#x3000;</li>
<li>prefixoverride&#xFF1A;&#x53BB;&#x6389;&#x7B2C;&#x4E00;&#x4E2A;and&#x6216;&#x8005;&#x662F;or&#x3000;&#x3000;&#x3000;</li>
</ul>
<p><strong>&#x7528; trim &#x6539;&#x5199;&#x4E0A;&#x9762;&#x7684; if+set &#x8BED;&#x53E5;</strong></p>
<pre><code class="lang-java">&lt;update id=&quot;updateStudentById&quot; parameterType=&quot;cn.kgc.mybatis.pojo.Student&quot;&gt;
    update student stu
       &lt;trim prefix=&quot;set&quot; suffixOverrides=&quot;,&quot;&gt;
            &lt;if test=&quot;stuname != null and stuname != &apos;&apos;&quot;&gt;
                stu.stu_name = #{stuName},
            &lt;/if&gt;
            &lt;if test=&quot;stusex != null and stusex != &apos;&apos;&quot;&gt;
                stu.stu_sex = #{stuSex}
            &lt;/if&gt;
        &lt;/trim&gt;
     where id=#{id}
&lt;/update&gt;
</code></pre>
<ul>
<li>suffix&#xFF1A;&#x540E;&#x7F00;&#x3000;&#x3000;</li>
<li>suffixoverride&#xFF1A;&#x53BB;&#x6389;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x9017;&#x53F7;&#xFF08;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x5176;&#x4ED6;&#x7684;&#x6807;&#x8BB0;&#xFF0C;&#x5C31;&#x50CF;&#x662F;&#x4E0A;&#x9762;&#x524D;&#x7F00;&#x4E2D;&#x7684;and&#x4E00;&#x6837;&#xFF09;</li>
</ul>
<blockquote>
<h4 id="&#x52A8;&#x6001;sql-foreach-&#x8BED;&#x53E5;">&#x52A8;&#x6001;SQL: foreach &#x8BED;&#x53E5;</h4>
</blockquote>
<p>&#x9700;&#x6C42;&#xFF1A;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x67E5;&#x8BE2; user &#x8868;&#x4E2D; id &#x5206;&#x522B;&#x4E3A;1,2,3&#x7684;&#x7528;&#x6237;,sql&#x8BED;&#x53E5;&#xFF1A;</p>
<pre><code class="lang-mysql">select * from user where id=1 or id=2 or id=3

select * from user where id in (1,2,3)
</code></pre>
<p>&#x7528; foreach &#x6765;&#x6539;&#x5199; select * from user where id=1 or id=2 or id=3</p>
<pre><code class="lang-mysql">&lt;select id=&quot;selectUserByListId&quot; parameterType=&quot;com.ys.vo.UserVo&quot; resultType=&quot;com.ys.po.User&quot;&gt;
    select * from user
    &lt;where&gt;
        &lt;!--
            collection:&#x6307;&#x5B9A;&#x8F93;&#x5165;&#x5BF9;&#x8C61;&#x4E2D;&#x7684;&#x96C6;&#x5408;&#x5C5E;&#x6027;
            item:&#x6BCF;&#x6B21;&#x904D;&#x5386;&#x751F;&#x6210;&#x7684;&#x5BF9;&#x8C61;
            open:&#x5F00;&#x59CB;&#x904D;&#x5386;&#x65F6;&#x7684;&#x62FC;&#x63A5;&#x5B57;&#x7B26;&#x4E32;
            close:&#x7ED3;&#x675F;&#x65F6;&#x62FC;&#x63A5;&#x7684;&#x5B57;&#x7B26;&#x4E32;
            separator:&#x904D;&#x5386;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x9700;&#x8981;&#x62FC;&#x63A5;&#x7684;&#x5B57;&#x7B26;&#x4E32;
            select * from user where 1=1 and (id=1 or id=2 or id=3)
          --&gt;
        &lt;foreach collection=&quot;ids&quot; item=&quot;id&quot; separator=&quot;or&quot;&gt;
            id=#{id}
        &lt;/foreach&gt;
    &lt;/where&gt;
&lt;/select&gt;
</code></pre>
<p>&#x7528; foreach &#x6765;&#x6539;&#x5199; select * from user where id in (1,2,3)</p>
<pre><code class="lang-mysql">&lt;select id=&quot;selectUserByListId&quot; parameterType=&quot;com.ys.vo.UserVo&quot; resultType=&quot;com.ys.po.User&quot;&gt;
        select * from user 
        &lt;where&gt;
            &lt;!--
                collection:&#x6307;&#x5B9A;&#x8F93;&#x5165;&#x5BF9;&#x8C61;&#x4E2D;&#x7684;&#x96C6;&#x5408;&#x5C5E;&#x6027;
                item:&#x6BCF;&#x6B21;&#x904D;&#x5386;&#x751F;&#x6210;&#x7684;&#x5BF9;&#x8C61;
                open:&#x5F00;&#x59CB;&#x904D;&#x5386;&#x65F6;&#x7684;&#x62FC;&#x63A5;&#x5B57;&#x7B26;&#x4E32;
                close:&#x7ED3;&#x675F;&#x65F6;&#x62FC;&#x63A5;&#x7684;&#x5B57;&#x7B26;&#x4E32;
                separator:&#x904D;&#x5386;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x9700;&#x8981;&#x62FC;&#x63A5;&#x7684;&#x5B57;&#x7B26;&#x4E32;
                select * from user where1=1 and id in (1,2,3)
              --&gt;
            &lt;foreach collection=&quot;ids&quot; item=&quot;id&quot; open=&quot;id in (&quot;separator=&quot;,&quot; close=&quot;) &quot; &gt;
                #{id}
            &lt;/foreach&gt;
        &lt;/where&gt;
 &lt;/select&gt;
</code></pre>
<blockquote>
<h4 id="&#x52A8;&#x6001;sql-sql-&#x7247;&#x6BB5;">&#x52A8;&#x6001;SQL: SQL &#x7247;&#x6BB5;</h4>
</blockquote>
<p>&#x6709;&#x65F6;&#x5019;&#x53EF;&#x80FD;&#x67D0;&#x4E2A; sql &#x8BED;&#x53E5;&#x6211;&#x4EEC;&#x7528;&#x7684;&#x7279;&#x522B;&#x591A;&#xFF0C;&#x4E3A;&#x4E86;&#x589E;&#x52A0;&#x4EE3;&#x7801;&#x7684;&#x91CD;&#x7528;&#x6027;&#xFF0C;&#x7B80;&#x5316;&#x4EE3;&#x7801;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5C06;&#x8FD9;&#x4E9B;&#x4EE3;&#x7801;&#x62BD;&#x53D6;&#x51FA;&#x6765;&#xFF0C;&#x7136;&#x540E;&#x4F7F;&#x7528;&#x65F6;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x3002;</p>
<p>&#x5047;&#x5982;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7ECF;&#x5E38;&#x6839;&#x636E;&#x7528;&#x6237;&#x540D;&#x548C;&#x6027;&#x522B;&#x6765;&#x8FDB;&#x884C;&#x8054;&#x5408;&#x67E5;&#x8BE2;&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x5C31;&#x628A;&#x8FD9;&#x4E2A;&#x4EE3;&#x7801;&#x62BD;&#x53D6;&#x51FA;&#x6765;&#xFF0C;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-java">&lt;sql id=&quot;selectUserByUserNameAndSexSQL&quot;&gt;
    &lt;if test=&quot;username != null and username != &apos;&apos;&quot;&gt;
        AND username = #{username}
    &lt;/if&gt;    
    &lt;if test=&quot;sex != null and sex != &apos;&apos;&quot;&gt;
        AND sex = #{sex}
    &lt;/if&gt;
&lt;/sql&gt;
</code></pre>
<pre><code class="lang-java">&lt;select id=&quot;selectUserByUsernameAndSex&quot; resultType=&quot;user&quot; parameterType=&quot;com.ys.po.User&quot;&gt;
    select * from user
    &lt;trim prefix=&quot;where&quot; prefixOverrides=&quot;and | or&quot;&gt;
        &lt;!-- &#x5F15;&#x7528; sql &#x7247;&#x6BB5;&#xFF0C;&#x5982;&#x679C;refid &#x6307;&#x5B9A;&#x7684;&#x4E0D;&#x5728;&#x672C;&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x90A3;&#x4E48;&#x9700;&#x8981;&#x5728;&#x524D;&#x9762;&#x52A0;&#x4E0A; namespace --&gt;
        &lt;include refid=&quot;selectUserByUserNameAndSexSQL&quot;&gt;&lt;/include&gt;
        &lt;!-- &#x5728;&#x8FD9;&#x91CC;&#x8FD8;&#x53EF;&#x4EE5;&#x5F15;&#x7528;&#x5176;&#x4ED6;&#x7684; sql &#x7247;&#x6BB5; --&gt;
    &lt;/trim&gt;
&lt;/select&gt;
</code></pre>
<p><code>&#x6CE8;&#x610F;&#xFF1A;</code>&#x2460;&#x3001;&#x6700;&#x597D;&#x57FA;&#x4E8E; &#x5355;&#x8868;&#x6765;&#x5B9A;&#x4E49; sql &#x7247;&#x6BB5;&#xFF0C;&#x63D0;&#x9AD8;&#x7247;&#x6BB5;&#x7684;&#x53EF;&#x91CD;&#x7528;&#x6027;</p>
<p>&#x3000;&#x3000;&#x3000;  &#x2461;&#x3001;&#x5728; sql &#x7247;&#x6BB5;&#x4E2D;&#x6700;&#x597D;&#x4E0D;&#x8981;&#x5305;&#x62EC; where </p>
<h2 id="mybatis&#x6CE8;&#x89E3;&#x5F00;&#x53D1;">mybatis&#x6CE8;&#x89E3;&#x5F00;&#x53D1;</h2>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">StudentDao2</span> </span>{

    <span class="hljs-meta">@Select</span>(<span class="hljs-string">&quot;select * from student where stu_no = #{stu_no}&quot;</span>)
    <span class="hljs-meta">@Results</span>({
            <span class="hljs-meta">@Result</span>(property = <span class="hljs-string">&quot;stuNo&quot;</span> ,column=<span class="hljs-string">&quot;stu_no&quot;</span>),
            <span class="hljs-meta">@Result</span>(property = <span class="hljs-string">&quot;stuSex&quot;</span>,column = <span class="hljs-string">&quot;stu_sex&quot;</span>),
            <span class="hljs-meta">@Result</span>(property = <span class="hljs-string">&quot;birth&quot;</span>,column = <span class="hljs-string">&quot;stu_birth&quot;</span>)
    })
   <span class="hljs-function">List&lt;Student&gt; <span class="hljs-title">getAll</span><span class="hljs-params">(String stu_no)</span></span>;

    <span class="hljs-meta">@Insert</span>(<span class="hljs-string">&quot;insert into student (stu_no,stu_name,stu_sex,stu_birth)values(#{stuNo},#{stuName},#{stuSex},#{birth})&quot;</span>)
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">addStudent</span><span class="hljs-params">(Student student)</span></span>;

    <span class="hljs-meta">@Delete</span>(<span class="hljs-string">&quot;delete from student where stu_no = #{stu_no}&quot;</span>)
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">delOne</span><span class="hljs-params">(String stu_no)</span></span>;

    <span class="hljs-meta">@Update</span>(<span class="hljs-string">&quot;update student set stu_name = #{stuName} where stu_no = #{stuNo}&quot;</span>)
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">uptStudent</span><span class="hljs-params">(Student student)</span></span>;

}
</code></pre>
<h2 id="mybatis&#x7F13;&#x5B58;">mybatis&#x7F13;&#x5B58;</h2>
<p>MyBatis &#x4E2D;&#x7684;&#x7F13;&#x5B58;&#x5C31;&#x662F;&#x8BF4; MyBatis &#x5728;&#x6267;&#x884C;&#x4E00;&#x6B21;SQL&#x67E5;&#x8BE2;&#x6216;&#x8005;SQL&#x66F4;&#x65B0;&#x4E4B;&#x540E;&#xFF0C;&#x8FD9;&#x6761;SQL&#x8BED;&#x53E5;&#x5E76;&#x4E0D;&#x4F1A;&#x6D88;&#x5931;&#xFF0C;&#x800C;&#x662F;&#x88AB;MyBatis &#x7F13;&#x5B58;&#x8D77;&#x6765;&#xFF0C;&#x5F53;&#x518D;&#x6B21;&#x6267;&#x884C;&#x76F8;&#x540C;SQL&#x8BED;&#x53E5;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x4F1A;&#x76F4;&#x63A5;&#x4ECE;&#x7F13;&#x5B58;&#x4E2D;&#x8FDB;&#x884C;&#x63D0;&#x53D6;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x518D;&#x6B21;&#x6267;&#x884C;SQL&#x547D;&#x4EE4;&#x3002;</p>
<p>mybatis&#x7684;&#x7F13;&#x5B58;&#x673A;&#x5236;&#x6709;&#x4E24;&#x7EA7;&#xFF1A;</p>
<p>&#xFF08;1&#xFF09;&#x4E00;&#x7EA7;&#x7F13;&#x5B58;&#xFF1A;&#x4E00;&#x7EA7;&#x7F13;&#x5B58;mybatsi&#x5DF2;&#x7ECF;&#x4E3A;&#x6211;&#x4EEC;&#x81EA;&#x52A8;&#x5F00;&#x542F;&#xFF0C;&#x4E0D;&#x7528;&#x6211;&#x4EEC;&#x624B;&#x52A8;&#x64CD;&#x4F5C;&#xFF0C;&#x800C;&#x4E14;&#x6211;&#x4EEC;&#x662F;&#x5173;&#x95ED;&#x4E0D;&#x4E86;&#x7684;&#xFF01;&#xFF01;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x624B;&#x52A8;&#x6E05;&#x9664;&#x7F13;&#x5B58;&#x3002;&#xFF08;SqlSession&#x7EA7;&#x522B;.&#x63D0;&#x4EA4;&#x4E8B;&#x52A1;&#xFF0C;&#x7F13;&#x5B58;&#x6E05;&#x7A7A;&#xFF09;</p>
<p>&#x200B;    <strong>&#x4E00;&#x7EA7;&#x7F13;&#x5B58;&#x5931;&#x6548;&#x7684;&#x60C5;&#x51B5;&#xFF1A;</strong></p>
<pre><code class="lang-html">1.&#x4E0D;&#x540C;&#x7684;SqlSession&#x5BF9;&#x5E94;&#x4E0D;&#x540C;&#x7684;&#x7F13;&#x5B58;
2.&#x540C;&#x4E00;&#x4E2A;SqlSession&#x4F46;&#x662F;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#x4E0D;&#x540C;
3.&#x540C;&#x4E00;&#x4E2A;SqlSession&#x6267;&#x884C;&#x4E24;&#x6B21;&#x76F8;&#x540C;&#x67E5;&#x8BE2;&#x4E4B;&#x95F4;&#x505A;&#x4E86;&#x589E;&#x5220;&#x6539;&#x7684;&#x64CD;&#x4F5C;
4.&#x540C;&#x4E00;&#x4E2A;SqlSession&#x6267;&#x884C;&#x4E24;&#x6B21;&#x76F8;&#x540C;&#x67E5;&#x8BE2;&#x4E4B;&#x95F4;&#x624B;&#x52A8;&#x6E05;&#x7A7A;&#x7F13;&#x5B58;
</code></pre>
<p>&#xFF08;2&#xFF09;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#xFF1A;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x624B;&#x52A8;&#x5F00;&#x542F;&#x3002;&#xFF08;&#x5168;&#x5C40;&#x7EA7;&#x522B;  SqlSessionFactory&#xFF09;</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!--&#x5F00;&#x542F;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;--&gt;</span>

&#x5F00;&#x542F;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x9700;&#x8981;&#x4E24;&#x4E2A;&#x6B65;&#x9AA4;&#xFF0C;&#x7B2C;&#x4E00;&#x6B65;&#x5728;mybatis&#x7684;&#x5168;&#x5C40;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x914D;&#x7F6E;Setting&#x5C5E;&#x6027;&#xFF0C;&#x8BBE;&#x7F6E;&#x540D;&#x4E3A;cacheEnabled&#x7684;&#x5C5E;&#x6027;&#x503C;&#x4E3A;true&#x5373;&#x53EF;
<span class="hljs-tag">&lt;<span class="hljs-name">settings</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- 
            (1):&#x5F00;&#x542F;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;,&#x8FD9;&#x4E2A;&#x5168;&#x5C40;&#x7684;&#x914D;&#x7F6E;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;
                   &#x9ED8;&#x8BA4;&#x662F;&#x5F00;&#x542F;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x8FD8;&#x662F;&#x9700;&#x8981;&#x5199;&#x4E0A;&#xFF0C;&#x9632;&#x6B62;&#x7248;&#x672C;&#x7684;&#x66F4;&#x65B0; 
        --&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">setting</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;cacheEnabled&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;true&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">settings</span>&gt;</span>    

&#x7B2C;&#x4E8C;&#x6B65;&#xFF1A;&#x5728;&#x5177;&#x4F53;&#x9700;&#x8981;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x7684;mapeer&#x6620;&#x5C04;&#x6587;&#x4EF6;&#x4E2D;&#x5F00;&#x542F;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#xFF0C;&#x503C;&#x9700;&#x8981;&#x5728;&#x76F8;&#x5E94;&#x7684;&#x6620;&#x5C04;&#x6587;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;cache&#x6807;&#x7B7E;&#x5373;&#x53EF;
2):&#x5728;&#x76F8;&#x5E94;&#x7684;&#x6620;&#x5C04;&#x6587;&#x4EF6;&#x4E2D;&#x5F00;&#x542F;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;
<span class="hljs-comment">&lt;!-- &#x5F00;&#x542F;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58; --&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-name">cache</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">cache</span>&gt;</span>
3)&#x67E5;&#x8BE2;&#x6570;&#x636E;&#x5C01;&#x88C5;&#x7684;&#x5B9E;&#x4F53;&#x7C7B;&#x8981;&#x5B9E;&#x73B0;&#x5E8F;&#x5217;&#x5316;&#x7684;&#x63A5;&#x53E3;
4)&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x9700;&#x8981;&#x5728;&#x4E00;&#x7EA7;&#x7F13;&#x5B58;&#x5173;&#x95ED;&#x6216;&#x8005;&#x63D0;&#x4EA4;&#x540E;&#x751F;&#x6548;

&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x5931;&#x6548;&#x7684;&#x6761;&#x4EF6;&#xFF1A;
1.&#x5728;&#x4E24;&#x6B21;&#x67E5;&#x8BE2;&#x4E4B;&#x95F4;&#x8FDB;&#x884C;&#x4E86;&#x4EFB;&#x610F;&#x7684;&#x589E;&#x5220;&#x6539;&#x64CD;&#x4F5C;&#xFF0C;&#x4E00;&#x7EA7;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x540C;&#x65F6;&#x5931;&#x6548;
</code></pre>
<pre><code class="lang-java"> <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test02</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x9A8C;&#x8BC1;mybatis&#x7684;&#x7F13;&#x5B58;&#x673A;&#x5236;  &#x4E00;&#x7EA7;&#x7F13;&#x5B58; &#x9ED8;&#x8BA4;&#x5F00;&#x542F; sqlsession&#x7EA7;&#x522B;</span>

        <span class="hljs-keyword">try</span> {
            InputStream resource = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            SqlSessionFactory factory = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(resource);
            SqlSession sqlSession = factory.openSession(<span class="hljs-keyword">true</span>);
            StudentDao mapper1 = sqlSession.getMapper(StudentDao.class);
            StudentDao mapper2 = sqlSession.getMapper(StudentDao.class);
            System.out.println(mapper1);
            System.out.println(mapper2);
            List&lt;Student&gt; a1 = mapper1.getAll();
            System.out.println(a1);
            <span class="hljs-comment">//&#x624B;&#x52A8;&#x63D0;&#x4EA4;&#x4E8B;&#x52A1; &#x6E05;&#x7A7A;&#x7F13;&#x5B58;</span>
            sqlSession.commit();
            List&lt;Student&gt; a2 = mapper2.getAll();
            System.out.println(a2);

            sqlSession.close();
        } <span class="hljs-keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }
    }


    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test03</span><span class="hljs-params">()</span></span>{<span class="hljs-comment">//&#x9A8C;&#x8BC1;mybatis&#x7684;&#x7F13;&#x5B58;&#x673A;&#x5236;  &#x4E8C;&#x7EA7;&#x7F13;&#x5B58; &#x9700;&#x8981;&#x914D;&#x7F6E;mybatis-config.xml  &#x548C;mapper&#x6587;&#x4EF6;</span>

        <span class="hljs-keyword">try</span> {
            InputStream resource = Resources.getResourceAsStream(<span class="hljs-string">&quot;config/mybatis-config.xml&quot;</span>);
            SqlSessionFactory factory = <span class="hljs-keyword">new</span> SqlSessionFactoryBuilder().build(resource);
            SqlSession sqlSession1 = factory.openSession(<span class="hljs-keyword">true</span>);
            SqlSession sqlSession2 = factory.openSession(<span class="hljs-keyword">true</span>);
            SqlSession sqlSession3 = factory.openSession(<span class="hljs-keyword">true</span>);

            StudentDao mapper1 = sqlSession1.getMapper(StudentDao.class);
            StudentDao mapper2 = sqlSession2.getMapper(StudentDao.class);
            StudentDao mapper3 = sqlSession3.getMapper(StudentDao.class);
            List&lt;Student&gt; a1 = mapper1.getAll();
            System.out.println(a1);
            <span class="hljs-comment">//&#x5173;&#x95ED;session&#x5C06;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x5199;&#x5165;&#x4E8C;&#x7EA7;&#x7F13;&#x5B58;</span>
            sqlSession1.close();

            <span class="hljs-comment">//&#x5F53;&#x5BF9;&#x540C;&#x4E00;&#x5F20;&#x8868;&#x8FDB;&#x884C;&#x589E;&#x5220;&#x6539;&#x64CD;&#x4F5C;&#x540E;  &#x4E8C;&#x7EA7;&#x7F13;&#x5B58;&#x6E05;&#x9664;</span>
            mapper3.delStudent(<span class="hljs-string">&quot;2021072901&quot;</span>);
           <span class="hljs-comment">// sqlSession3.close();</span>

            List&lt;Student&gt; a2 = mapper2.getAll();
            System.out.println(a2);

        } <span class="hljs-keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }
    }
</code></pre>
<h2 id="mybatis&#x5206;&#x9875;&#x63D2;&#x4EF6;">mybatis&#x5206;&#x9875;&#x63D2;&#x4EF6;</h2>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.github.pagehelper<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>pagehelper<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.2.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!--&#x5728;mybatis&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D; &#x914D;&#x7F6E;mybatis&#x63D2;&#x4EF6; --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">plugins</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">plugin</span> <span class="hljs-attr">interceptor</span>=<span class="hljs-string">&quot;com.github.pagehelper.PageInterceptor&quot;</span>&gt;</span>
            <span class="hljs-comment">&lt;!-- &#x914D;&#x7F6E;mysql&#x65B9;&#x8A00; --&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;helperDialect&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;mysql&quot;</span> /&gt;</span>
            <span class="hljs-comment">&lt;!-- &#x8BBE;&#x7F6E;&#x4E3A;true&#x65F6;&#xFF0C;&#x5982;&#x679C;pageSize=0&#x5C31;&#x4F1A;&#x67E5;&#x8BE2;&#x51FA;&#x5168;&#x90E8;&#x7684;&#x7ED3;&#x679C; --&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;pageSizeZero&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;true&quot;</span> /&gt;</span>
            <span class="hljs-comment">&lt;!-- 3.3.0&#x7248;&#x672C;&#x53EF;&#x7528;&#xFF0C;&#x5206;&#x9875;&#x53C2;&#x6570;&#x5408;&#x7406;&#x5316;&#xFF0C;&#x9ED8;&#x8BA4;false&#x7981;&#x7528; --&gt;</span>
            <span class="hljs-comment">&lt;!-- &#x542F;&#x7528;&#x5408;&#x7406;&#x5316;&#x65F6;&#xFF0C;&#x5982;&#x679C;pageNum&lt;1&#x4F1A;&#x67E5;&#x8BE2;&#x7B2C;&#x4E00;&#x9875;&#xFF0C;&#x5982;&#x679C;pageNum&gt;pages&#x4F1A;&#x67E5;&#x8BE2;&#x6700;&#x540E;&#x4E00;&#x9875; --&gt;</span>
            <span class="hljs-comment">&lt;!-- &#x7981;&#x7528;&#x5408;&#x7406;&#x5316;&#x65F6;&#xFF0C;&#x5982;&#x679C;pageNum&lt;1&#x6216;pageNum&gt;pages&#x4F1A;&#x8FD4;&#x56DE;&#x7A7A;&#x6570;&#x636E; --&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;reasonable&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;true&quot;</span> /&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">plugin</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">plugins</span>&gt;</span>
</code></pre>
<p><strong>&#x5B9E;&#x4F8B;</strong></p>
<pre><code class="lang-java"> <span class="hljs-comment">// &#x6D4B;&#x8BD5;&#x5206;&#x9875;&#x63D2;&#x4EF6;&#x7684;&#x4F7F;&#x7528;</span>
    <span class="hljs-meta">@Test</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span>  <span class="hljs-title">test06</span><span class="hljs-params">()</span></span>{
        SqlSession session = factory.openSession(<span class="hljs-keyword">true</span>);
        StudentDao mapper = session.getMapper(StudentDao.class);
        PageHelper.startPage(<span class="hljs-number">5</span>, <span class="hljs-number">3</span>);
        List&lt;Student&gt; all = mapper.findAll();
        PageInfo&lt;Student&gt; pageInfo = <span class="hljs-keyword">new</span> PageInfo&lt;&gt;(all);

        <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5206;&#x9875;&#x7684;&#x76F8;&#x5173;&#x6570;&#x636E;</span>
        System.out.println(pageInfo);
        <span class="hljs-comment">//&#x83B7;&#x53D6;&#x603B;&#x6761;&#x6570;</span>
        <span class="hljs-keyword">long</span> total = pageInfo.getTotal();
        System.out.println(total);
        <span class="hljs-comment">//&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x9875;&#x7684;&#x663E;&#x793A;&#x6570;&#x636E;</span>
        List&lt;Student&gt; list = pageInfo.getList();
        list.forEach(student-&gt; System.out.println(student));

    }
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="SpringBoot.html" class="navigation navigation-next navigation-unique" aria-label="Next page: SpringBoot">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Mybatis框架","level":"2.6.1","depth":2,"next":{"title":"SpringBoot","level":"2.6.2","depth":2,"path":"books/整合/SpringBoot.md","ref":"books/整合/SpringBoot.md","articles":[]},"previous":{"title":"整合","level":"2.6","depth":1,"ref":"","articles":[{"title":"Mybatis框架","level":"2.6.1","depth":2,"path":"books/整合/Mybatis框架.md","ref":"books/整合/Mybatis框架.md","articles":[]},{"title":"SpringBoot","level":"2.6.2","depth":2,"path":"books/整合/SpringBoot.md","ref":"books/整合/SpringBoot.md","articles":[]},{"title":"Springmvc框架","level":"2.6.3","depth":2,"path":"books/整合/springmvc框架.md","ref":"books/整合/springmvc框架.md","articles":[]},{"title":"Spring框架","level":"2.6.4","depth":2,"path":"books/整合/spring框架.md","ref":"books/整合/spring框架.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["search-pro","code","back-to-top-button","theme-comscore","intopic-toc","flexible-alerts","expandable-chapters"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"intopic-toc":{"selector":".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section h5, .markdown-section h6","mode":"nested","maxDepth":6,"isCollapsed":true,"isScrollspyActive":true,"visible":true,"label":"In this article"},"search-pro":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"flexible-alerts":{"style":"callout","note":{"label":"Note","icon":"fa fa-info-circle","className":"info"},"tip":{"label":"Tip","icon":"fa fa-lightbulb-o","className":"tip"},"warning":{"label":"Warning","icon":"fa fa-exclamation-triangle","className":"warning"},"danger":{"label":"Attention","icon":"fa fa-ban","className":"danger"}},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"作者","lang":"zh-cn","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"图书编号","variables":{},"title":"书名","gitbook":"*","description":"描述"},"file":{"path":"books/整合/Mybatis框架.md","mtime":"2022-11-23T10:40:10.998Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-01T12:24:55.135Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

